<!Doctype html>
<html>

<head>
    <title>oixan的博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html" ; charset="utf-8">
    <link rel="stylesheet" type="text/css" href="../css/blog.css">
</head>

<body>
    <div class="head">
        <div class="headnav">
            <div class="naveframe">
                <ul class="navlist">
                    <li>
                        <a href="../index.html">
                            主页
                        </a>
                    </li>
                    <li>
                        <a href="../bloglist.html">
                            博客
                        </a>
                    </li>
                    <li>
                        <a href="../about.html">
                            关于
                        </a>
                    </li>
                </ul>
            </div>
        </div>

        <div class="headtext">
            <div class="headtext1">世界很简单，人类很复杂。</div>
            <div class="headtext2">浮生若梦，寻寻觅觅。</div>
        </div>
    </div>

    <div class="contents-all">
        <div class="contents">

            <div class="frame">
                <div class="title">
                    <h3>查jd商品参数python</h3>
                </div>
                <div class="dtime">时间：2018-06-19</div>
                <div class="detail">

                    <p>
                        <span style="font-size: 14px;">import requests</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">import json</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">from bs4 import BeautifulSoup</span>
                    </p>
                    <p>
                        <br/>
                    </p>
                    <p>
                        <span style="font-size: 14px;">id=&#39;6610412&#39;</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">url=&#39;https://item.jd.com/&#39;+id+&#39;.html&#39;</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">prurl=&#39;https://p.3.cn/prices/mgets?skuIds=J_&#39;+id</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">smry=requests.get(url).content</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">prsmry=requests.get(prurl).json()</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">soup=BeautifulSoup(smry,&#39;lxml&#39;)</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">pr=prsmry[0][&#39;p&#39;]</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">pt=soup.find_all(class_=&#39;Ptable&#39;)</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">print(pr)</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">p=pt[0].get_text()</span>
                    </p>
                    <p>
                        <span style="font-size: 14px;">print(p)</span>
                    </p>
                    <p>
                        <img src="../img/blogimg/201806191.jpg" style="width: 50%;" title="" alt="jdpython.jpg" />
                    </p>


                </div>
<a href="javascript:void(0)" onclick="showPg()">返回</a>
            </div>


        </div>
    </div>
    <div class="footer">
        <div class="footertext">©2018,oixan博客</div>
    </div>
    <span id="backtop" onclick="topFunction()">返回顶部</span>
</body>
<script  src="../js/fanhuiye.js"></script>
</html>